using System.Data;
using System.Data.SqlClient;
using VanTaiProperty;
namespace VanTaiData
{
    public class clsTMUnit_VehicleController
    {
        private clsConnect cls = new clsConnect();
        private DataTable dt;
        #region[Get-Data]
        public DataTable BindGirdTMUnit_Vehicle()
        {
            return cls.BindGridData("sp_TMUnit_Vehicle");
        }
        public DataTable BindGirdTMUnit_Vehicle_Detail_Edit(int id)
        {
            return cls.LayDuLieuParameter("sp_TMUnit_Vehicle_Detail_Edit","@Unit_Vehicle_ID", id);
        }
        #endregion

        #region[Insert-Update-Delete]
        public bool InsertTMUnit_Vehicle(clsTMUnit_VehicleProperty data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Unit_Block_Vehicle_ID", data.Unit_Block_Vehicle_ID);
            cls.AddParameter("@Unit_Vehicle_Alias", data.Unit_Vehicle_Alias);
            cls.AddParameter("@Unit_Vehicle_Name", data.Unit_Vehicle_Name);
            cls.AddParameter("@Unit_Vehicle_Number", data.Unit_Vehicle_Number);
            cls.ExecuteNonQuery("sp_TMUnit_Vehicle_Insert");
            return true;
        }
        public bool UpdateTMUnit_Vehicle(clsTMUnit_VehicleProperty data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Unit_Vehicle_ID", data.Unit_Vehicle_ID);
            cls.AddParameter("@Unit_Block_Vehicle_ID", data.Unit_Block_Vehicle_ID);
            cls.AddParameter("@Unit_Vehicle_Alias", data.Unit_Vehicle_Alias);
            cls.AddParameter("@Unit_Vehicle_Name", data.Unit_Vehicle_Name);
            cls.AddParameter("@Unit_Vehicle_Number", data.Unit_Vehicle_Number);
            cls.ExecuteNonQuery("sp_TMUnit_Vehicle_Update");
            return true;
        }
        public bool DeleteTMUnit_Vehicle(int id)
        {
            cls.Delete("sp_TMUnit_Vehicle_Delete", "@Unit_Vehicle_ID", id);
            return true;
        }
        public bool TMUnit_Vehicle_Check_Delete_TMType_Vehicle(int id)
        {
            dt = cls.LayDuLieuParameter("sp_TMUnit_Vehicle_Check_Delete_TMType_Vehicle", "@Id", id);
            if (dt.Rows.Count > 0)
                return true;
            return false;
        }
        #endregion

        #region[Search]
        public DataTable Search(string keywords)
        {
            return cls.Search("sp_TMUnit_Vehicle_Search", "@KEYWORDS", keywords);
        }
        #endregion
    }
}